home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / user / viewnextweeksschedule.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  9KB  |  317 lines

  1. /* Mode=Run */
  2. /* ***********************************************************************
  3.  
  4.    VIEW NEXT WEEKS SCHEDULE PROGRAM FOR FOOTBALL REXX SUITE
  5.   ----------------------------------------------------------
  6.                    Copyright  Mark Naughton 1997
  7.  
  8.  
  9. Version    Date     History
  10. --------------------------------------------------------------------------
  11.  1.0       071097   First release.
  12.            151297   Tidied display.
  13.            250899   Added error msg to file checks.
  14.            110999   Converted to use locale. Some error messages, before
  15.                     reading the locale, will still be in English.
  16.                     Converted to use a global date format file. Now correctly
  17.                     translates date format to get required data.
  18.            190999   Changed schedule directory.
  19.  
  20. **************************************************************************
  21.  
  22. Procedure
  23. ---------
  24.  
  25. 1. Check files exist. Read Teams.df datafile and store league name. Check
  26.    for autoscheduled.
  27. 2. If league has not been autoscheduled then give an error and quit.
  28. 3. Open AutoSchedule file and find the type.
  29. 4. Set range for the dates.
  30. 5. Display the header.
  31. 6. Open '.sf' file. Search for matches played during the next week...
  32. 7. If Weeks, if a match is found then display the formatted data. But
  33.    when a new week is found, goto (9).
  34. 8. If Dates, format the date from the line read from the file and if
  35.    it is within the two dates, format the data and display.
  36. 9. When the file is finished, print the number of matches and exit...
  37.  
  38. ************************************************************************** */
  39. PARSE ARG league_stuff
  40.  
  41. version      = 1
  42. input_file   = '.df'
  43. input2_file  = '.sf'
  44. title        = '*LEAGUE_NAME='
  45. autosched    = '*AUTOSCHD='
  46. separator    = '*'
  47. not_played   = '__   __'
  48. months       = "January February March April May June July August September October November December"
  49.  
  50.  
  51. parse var league_stuff league_file
  52. league_file = "Data/" || league_file
  53.  
  54. addlib('rexxsupport.library',0,-30,0)
  55.  
  56. if open(datafile,"Data/Football.locale",'r') then do
  57.    line = readln(datafile)
  58.    locdir = strip(line)
  59.    close(datafile)
  60. end
  61. else do
  62.    say
  63.    say "ERROR :    (ViewNextWeeksSchedule)"
  64.    say
  65.    say "Cannot read 'Data/Football.locale' for the locale settings."
  66.    exit
  67. end
  68.  
  69. dfordir = locdir"Football.locale_data"
  70. locdir = locdir"User/ViewNextWeeksSchedule.data"
  71.  
  72. if open(datafile,"ENV:FootballRXPath",'r') then do
  73.    line = readln(datafile)
  74.    rxdir = strip(line)
  75.    close(datafile)
  76. end
  77. else
  78.    rxdir = "SYS:Rexxc/"
  79.  
  80. if exists(locdir) > 0 then do
  81.   address command rxdir'rx 'locdir
  82.   VarCount = getclip('VarCount')
  83.   do i = 1 to VarCount
  84.     interpret getclip('var.'i)
  85.   end
  86. end
  87. else do
  88.    say
  89.    say "ERROR :    (ViewNextWeeksSchedule)"
  90.    say
  91.    say "Cannot find '"locdir"' to read locale settings."
  92.    exit
  93. end
  94.  
  95. if exists(dfordir) > 0 then do
  96.   address command rxdir'rx 'dfordir
  97.   VarCount = getclip('VarCount')
  98.   do i = 1 to VarCount
  99.     interpret getclip('var.'i)
  100.   end
  101. end
  102. else do
  103.    say
  104.    say "ERROR :    (ViewNextWeeksSchedule)"
  105.    say
  106.    say "Cannot find '"dfordir"' to read date locale settings."
  107.    exit
  108. end
  109.  
  110. if exists(league_file || input_file) = 0  then do
  111.    say
  112.    say vnws_error
  113.    say
  114.    say vnws_t1"'"league_file || input_file"'."
  115.    exit
  116. end
  117.  
  118. if exists(league_file || input2_file) = 0 then do
  119.    say
  120.    say vnws_error
  121.    say
  122.    say vnws_t1"'"league_file || input2_file"'."
  123.    exit
  124. end
  125.  
  126. autos = 0
  127. if open(datafile,league_file || input_file,'r') then do
  128.    do while ~eof(datafile)
  129.       line = readln(datafile)
  130.       if pos(title,line) > 0 then
  131.          league_title = delstr(line,1,13)
  132.       if pos(autosched,line) > 0 then do
  133.          autofile = delstr(line,1,10)
  134.          autos = 1
  135.       end
  136.    end
  137.    close(datafile)
  138. end
  139. else do
  140.    say
  141.    say vnws_error
  142.    say
  143.    say vnws_t2"'"league_file || input_file"'"vnws_t3
  144.    exit
  145. end
  146.  
  147. if autos = 0 then do
  148.    say
  149.    say vnws_error
  150.    say
  151.    say vnws_t4
  152.    say
  153.    say vnws_t5
  154.    say vnws_t6
  155.    say "'Teams6.schd'. "vnws_t7
  156.    say
  157.    exit
  158. end
  159.  
  160. type = 0
  161. if autos = 1 then do
  162.    if open(datafile,"Data/Schedules/"||autofile||".schd",'r') then do
  163.       line = readln(datafile)
  164.       if pos("*WEEKS",line) > 0 then
  165.          type = 10
  166.       if pos("*DATES",line) > 0 then
  167.          type = 20
  168.       close(datafile)
  169.    end
  170.    else do
  171.       say
  172.       say vnws_error
  173.       say
  174.       say vnws_t8" 'Data/Schedules/"autofile".schd' "vnws_t9
  175.       exit
  176.    end
  177. end
  178.  
  179. start_date = date('i')
  180. end_date   = start_date + 6
  181.  
  182. say
  183. say center(vnws_t10" '"league_title"'",78)
  184. say "-------------------------------------------------------------------------------"
  185. say
  186. say vnws_t11" '"autofile"' "vnws_t12
  187. say
  188. say
  189. if type=10 then
  190.    say vnws_t13
  191. else
  192.    say vnws_t14" "date('n',start_date,'i')" "vnws_t15" "date('n',end_date,'i')"."
  193. say
  194.  
  195. matches = 0
  196. s_l = 0
  197. if open(datafile,league_file || input2_file,'r') then do
  198.    do while ~eof(datafile)
  199.       line = readln(datafile)
  200.       if pos(separator,line) > 0 then do
  201.          if pos("*Week:",line) > 0 then do
  202.             curr = 10
  203.             if matches > 0 then
  204.                leave
  205.          end
  206.          if pos("*Date:",line) > 0 then do
  207.             if s_l = 0 then do
  208.                parse var line "*Date:" dateall
  209.                search_loc = strip(word(dateall,words(dateall)-1))
  210.                do mnls=1 to 12
  211.                   if pos(word(months,mnls),search_loc) > 0 then do
  212.                      s_l = 1
  213.                      leave
  214.                   end
  215.                end
  216.                if s_l = 0 then do
  217.                   locale_cats = showdir("Locale/")
  218.                   do search_locale=1 to words(locale_cats)
  219.                      dfordir = "Locale/"word(locale_cats,search_locale)"/Football.locale_data"
  220.                      if exists(dfordir) > 0 then do
  221.                        address command rxdir'rx 'dfordir
  222.                        VarCount = getclip('VarCount')
  223.                        do i = 1 to VarCount
  224.                          interpret getclip('var.'i)
  225.                        end
  226.                      end
  227.                      parse var line "*Date:" dateall
  228.                      search_loc = strip(word(dateall,words(dateall)-1))
  229.                      do mnls=1 to 12
  230.                         if pos(word(months,mnls),search_loc) > 0 then do
  231.                            s_l = 1
  232.                            leave
  233.                         end
  234.                      end
  235.                      if s_l = 1 then leave
  236.                   end
  237.                end
  238.                if s_l > 0 then do
  239.                   temp_dtal = dateall
  240.                   parse var date_format "day" sp1 "number" sp2 "month" sp3 "year"
  241.                   parse var line "*Date:" dateall
  242.                   do i=1 to 7
  243.                      if pos(word(days,i),dateall) > 0 then do
  244.                         lk = pos(word(days,i),dateall)
  245.                         dateall = delstr(dateall,1,lk+length(word(days,i))+length(sp1)-1)
  246.                      end
  247.                   end
  248.                   dateall = strip(dateall)
  249.                   year = word(dateall,words(dateall))
  250.                   mnth = strip(word(dateall,words(dateall)-1))
  251.                   do lm=1 to length(mnth)
  252.                      if datatype(substr(mnth,1,1),'m') ~= 1 then
  253.                         mnth = delstr(mnth,1,1)
  254.                   end
  255.                   dateall = temp_dtal
  256.                   day  = word(dateall,2)
  257.                   do lm=1 to length(day)-2
  258.                      if datatype(substr(day,3,1),'n') ~= 1 then
  259.                         day = delstr(day,3,1)
  260.                   end
  261.                   cv = 0
  262.                   do i=1 to 12
  263.                      if pos(word(months,i),mnth) > 0 then do
  264.                         cv = i
  265.                         leave
  266.                      end
  267.                   end
  268.                end
  269.             end
  270.             if s_l = 0 then do
  271.                say
  272.                say vnws_error
  273.                say
  274.                say vnws_t18
  275.                exit
  276.             end
  277.             curr = 0
  278. /*
  279.             year = word(line,5)
  280.             mnth = word(line,4)
  281.             day  = word(line,3)
  282. */
  283.             curd = trim(year)||right(cv,2,0)||right(day,2,0)
  284.             s_l = 0
  285.             if start_date <= date('i',curd,'s') & end_date >= date('i',curd,'s') then
  286.                curr = 10
  287.          end
  288.       end
  289.       if curr = 10 then do
  290.          if pos(separator,line) = 0 then do
  291.             if pos(not_played,line) > 0 then do
  292.                home_team = strip(substr(line,1,35))
  293.                away_team = strip(substr(line,41,35))
  294.                say left(home_team,30)""txt_versus""away_team
  295.                matches = matches + 1
  296.             end
  297.          end
  298.       end
  299.    end
  300.    close(datafile)
  301.    say
  302.    if matches = 0 then
  303.       say vnws_t16
  304.    else
  305.       say vnws_t17":  "matches
  306.    say
  307.    say "-------------------------------------------------------------------------------"
  308.    say
  309. end
  310. else do
  311.    say
  312.    say vnws_error
  313.    say
  314.    say vnws_t8"'"league_file || input2_file"'."
  315. end
  316.  
  317. exit